<template>
  <div class="repair-layout">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="220px">
        <div class="logo">维修管理系统</div>
        <el-menu
          router
          :default-active="$route.path"
          background-color="#304156"
          text-color="#bfcbd9"
          active-text-color="#409EFF"
        >
          <el-menu-item index="/repair/work-order">
            <el-icon><document /></el-icon>
            <span>维修工单管理</span>
          </el-menu-item>
          <el-menu-item index="/repair/repair-record">
            <el-icon><edit /></el-icon>
            <span>维修记录查看</span>
          </el-menu-item>
          <el-menu-item index="/repair/repair-progress">
            <el-icon><clock /></el-icon>
            <span>维修进度</span>
          </el-menu-item>
          <el-menu-item index="/repair/repair-report">
            <el-icon><data-line /></el-icon>
            <span>维修报表</span>
          </el-menu-item>
          <el-menu-item index="/repair/profile">
            <el-icon><user /></el-icon>
            <span>个人信息</span>
          </el-menu-item>
        </el-menu>
        
      </el-aside>

      <!-- 主内容区 -->
      <el-main>
        <router-view />
        <div class="logout-container">
          <el-button @click="handleLogout" type="danger" plain>退出登录</el-button>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import {
  Document,
  Edit,
  Box,
  Clock,
  DataLine,
  User
} from '@element-plus/icons-vue'
import { useUserStore } from '@/store/user'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const userStore = useUserStore()
const router = useRouter()

const handleLogout = () => {
  userStore.clearUserInfo()
  ElMessage.success('已退出登录')
  router.push('/auth/login')
}
</script>

<style scoped>
.repair-layout {
  height: 100vh;
}

.logo {
  height: 60px;
  line-height: 60px;
  text-align: center;
  color: #fff;
  background-color: #2b2f3a;
  font-size: 18px;
  font-weight: bold;
}

.el-aside {
  background-color: #304156;
  height: 100vh;
}

.el-menu {
  border-right: none;
}

.logout-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1;
}
</style>